package com.hs.sfzy.controller;

import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.Answer;
import com.hs.sfzy.service.AnswerService;
import com.hs.sfzy.until.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AnswerController
 * @Description TODO
 * @Author liuzhuo
 * @Date 2025年08月13日 15:34
 * @Version 1.0
 */
@RestController
@RequestMapping("/answer")
public class AnswerController {
    @Autowired
    private AnswerService answerService;
    @GetMapping("/page")
    public R getAnswerList(Answer answer,
                           @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                           @RequestParam(required = false, defaultValue = "10") Integer pageSize){
        PageInfo<Answer> pageInfo = answerService.getAnswerList(answer, pageNum, pageSize);
        return pageInfo==null?R.fail():R.ok(pageInfo);
    }
    @GetMapping("/getAnswersByContent")
    public R getAnswersByContent(String content){
        return answerService.getAnswersByContent(content)==null?R.fail():R.ok(answerService.getAnswersByContent(content));
    }
}
